// Use this when the unmanaged API expects the structure passed by-value, or
// or if you want to pass it by-reference as a pointer to a structure
struct OSVERSIONINFO {
public uint dwOSVersionInfoSize;
public uint dwMajorVersion;
public uint dwMinorVersion;
public uint dwBuildNumber;
public uint dwPlatformId;
[MarshalAs(UnmanagedType.ByValTStr, SizeConst = 128)]
public string szCSDVersion;
public Int16 wServicePackMajor;
public Int16 wServicePackMinor;
public Int16 wSuiteMask;
public Byte wProductType;
public Byte wReserved;
}
// Use this when you want to pass it by-value even though the unmanaged API
// expects a pointer to a structure. Being a class adds an extra level of indirection.
[StructLayout(LayoutKind.Sequential)]
class OSVERSIONINFO
{
public uint dwOSVersionInfoSize;
public uint dwMajorVersion;
public uint dwMinorVersion;
public uint dwBuildNumber;
public uint dwPlatformId;
[MarshalAs(UnmanagedType.ByValTStr, SizeConst = 128)]
public string szCSDVersion;
public Int16 wServicePackMajor;
public Int16 wServicePackMinor;
public Int16 wSuiteMask;
public Byte wProductType;
public Byte wReserved;
}
' Use this when the unmanaged API expects the structure passed by-value, or
' or if you want to pass it by-reference as a pointer to a structure
' If you plan to call "GetVersionExW" Use CharSet.Unicode
' If you are calling "GetVersionExA", Use CharSet.Ansi
<StructLayout(LayoutKind.Sequential, CharSet:=CharSet.Unicode)> _
Public Structure OSVERSIONINFO
Public dwOSVersionInfoSize As Int32
Public dwMajorVersion As Int32
Public dwMinorVersion As Int32
Public dwBuildNumber As Int32
Public dwPlatformId As Int32
<VBFixedString(128), MarshalAs( _
UnmanagedType.ByValTStr, SizeConst:=128)> _
Public szCSDVersion As String
Public wServicePackMajor As Int16
Public wServicePackMinor As Int16
Public wSuiteMask As Int16
Public wProductType As Byte
Public wReserved As Byte
End Structure
' Use this when you want to pass it by-value even though the unmanaged API
' expects a pointer to a structure. Being a class adds an extra level of indirection.
<StructLayout(LayoutKind.Sequential)> _
Class OSVERSIONINFO
Public dwOSVersionInfoSize As Int32
Public dwMajorVersion As Int32
Public dwMinorVersion As Int32
Public dwBuildNumber As Int32
Public dwPlatformId As Int32
<VBFixedString(128), MarshalAs( _
UnmanagedType.ByValTStr, SizeConst:=128)> _
Public szCSDVersion As String
Public wServicePackMajor As Int16
Public wServicePackMinor As Int16
Public wSuiteMask As Int16
Public wProductType As Byte
Public wReserved As Byte
End Class